<?php require _APP_PATH_ . '/system/platform/resource/common_inc_header.tpl.php';?>

<span class="layui-breadcrumb">
    <a href="<?php echo url( _MODULE_NAME_ . '/admin.index/index');?>"><?php echo $GLOBALS['config']['module']['name'];?></a>
    <a href="<?php echo url([ _MODULE_NAME_ ,'admin/goodssort','index']);?>">商品分类</a>
    <a><cite>添加</cite></a>
</span>

<div class="layui-tab layui-tab-brief">
    <ul class="layui-tab-title">
        <li class="layui-this"><a href="<?php echo url([ _MODULE_NAME_ ,'admin.goodssort','index']);?>">商品分类</a></li>
    </ul>
</div>

<form class="layui-form" action="<?php echo url([ _MODULE_NAME_ ,'admin/goodssort','goods_sort_save']);?>" method="post" style="max-width: 900px;margin: 40px auto;">

    <div class="layui-form-item">
        <label class="layui-form-label">名称：</label>
        <div class="layui-input-block">
            <input type="text" name="sort_name" placeholder="请输入名称" class="layui-input" 
                    lay-verType="tips" lay-verify="required" required/>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">所属分类：</label>
        <div class="layui-input-block">
            <select name="parent_id" lay-verify="required" required >
                <option value="0">顶级分类</option>
                <?php foreach($this->rs_sort as $row){ ?>
                    <option value="<?php echo $row['sort_id'];?>"><?php 
                        for($i=2;$i<substr_count($row['parent_path'],',');$i++){ echo '&nbsp; &nbsp; ├ ';}
                        echo $row['sort_name'];?></option>
                <?php } ?>
            </select>

        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">位置：</label>
        <div class="layui-input-block">
        <input type="text" name="place" placeholder="请输入显示位置" class="layui-input" value="" autocomplete="off" />
            <input type="radio" name="place_nav" value="自定义" title="自定义" lay-filter="place_nav" checked>
            <br>
            <input type="radio" name="place_nav" value="1屏左"   title="1屏左"   lay-filter="place_nav">
            <input type="radio" name="place_nav" value="1屏中"   title="1屏中"   lay-filter="place_nav">
            <input type="radio" name="place_nav" value="1屏右"   title="1屏右"   lay-filter="place_nav">
            <input type="radio" name="place_nav" value="1屏通栏" title="1屏通栏" lay-filter="place_nav">
            <br>
            <input type="radio" name="place_nav" value="2屏左"   title="2屏左"   lay-filter="place_nav">
            <input type="radio" name="place_nav" value="2屏中"   title="2屏中"   lay-filter="place_nav">
            <input type="radio" name="place_nav" value="2屏右"   title="2屏右"   lay-filter="place_nav">
            <input type="radio" name="place_nav" value="2屏通栏" title="2屏通栏" lay-filter="place_nav">
            <br>
            <input type="radio" name="place_nav" value="3屏左"   title="3屏左"   lay-filter="place_nav">
            <input type="radio" name="place_nav" value="3屏中"   title="3屏中"   lay-filter="place_nav">
            <input type="radio" name="place_nav" value="3屏右"   title="3屏右"   lay-filter="place_nav">
            <input type="radio" name="place_nav" value="3屏通栏" title="3屏通栏" lay-filter="place_nav">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">简介：</label>
        <div class="layui-input-block">
            <input type="text" name="tip" placeholder="请输入简介" class="layui-input"  lay-verType="tips"/>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">图标：</label>
        <div class="layui-input-block">
            <?php echo tpl_file_manager( [ 'sort_img' ] ); ?>
			<br style="clear:both">上传图片尺寸视网站效果自定
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">排序：</label>
        <div class="layui-input-block">
            <input type="number" name="list_order" placeholder="请输入排序数字" class="layui-input"  value="0"/>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">模板：</label>
        <div class="layui-input-block">
            <input type="radio" name="tpl_name" value="goods_list.tpl.php" title="默认" checked>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">状态：</label>
        <div class="layui-input-block">
            <input type="radio" name="status" value="1" title="启用" checked>
            <input type="radio" name="status" value="0" title="禁用" >
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" type="submit" lay-submit >&emsp;提交&emsp;</button>
        </div>
    </div>
</form>

<?php require _APP_PATH_ . '/system/platform/resource/common_inc_footer.tpl.php';?>

<script>
    layui.use(['layer', 'form', 'laydate'], function () {
        var $ = layui.jquery;
        var layer = layui.layer;
        var form = layui.form;
        var laydate = layui.laydate;

       
        // 显示位置
        form.on('radio(place_nav)', function(data){
            var v = data.value;
            if(data.value=='自定义'){
                v = '';
            }
            $('input[name=place]').val( v );
        });

    });
</script>